﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace LogisticsManagementSystem.Driver
{
    public partial class DriverManage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rptDriverList.DataSource = LogisticsBLL.DriverBLL.GetDriverManage();
                rptDriverList.DataBind();
            }
        }

        protected void rptDriverList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                LogisticsModel.Driver driver = (LogisticsModel.Driver)e.Item.DataItem;
                int driverid = driver.DriverID;//获取该驾驶员的id

                object number = LogisticsBLL.DriverBLL.GetTruckNumber(driverid);
                if (number != null)//有绑定车辆
                {
                    HtmlTableCell cell = e.Item.FindControl("tbNumber") as HtmlTableCell;
                    cell.InnerText = number.ToString();
                    LinkButton link = (LinkButton)e.Item.FindControl("btnUnBind");
                    link.Visible = true;
                }
                else
                {
                    LinkButton link = (LinkButton)e.Item.FindControl("btnBind");
                    link.Visible = true;
                }
            }


        }
    }
}